package Algorithms.recursion;

/**
 * description: 递归实现乘方<br>
 * createTime: 2018/10/3110:24 <br>
 *
 * @author zzh
 */
public class Power {

    public static int doPower(int val, int power) {
        if(power == 1) {
            return val;
        }
        int result = doPower(val, power / 2);
        if(power % 2 != 0) {
            return result * result * val;
        } else {
            return result * result;
        }
    }
    public static void main(String[] args) {
        System.out.println(doPower(2,15));
    }
}
